﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
namespace Xwork.SEO
{
    public class UserAuthorizeAttribute : AuthorizeAttribute
    {
        public UserAuthorizeAttribute()
        {
            RequireAdmin = false;
        }

        protected override bool AuthorizeCore(System.Web.HttpContextBase httpContext)
        {
            User user = (User)httpContext.Session["user"];
            return RequireAdmin ? user != null && user.IsAdmin : user != null;
        }


        public bool RequireAdmin { get; set; }
    }
}
